package samples.java.oom.heap;

/**
 * VM Args: -Xss200k
 *
 * @author wang.yuchuan
 * @createdAt 2018/12/11
 */
public class StackOOMSamples {

    public int stackLength = 1;

    public void stackLeak() {
        stackLength++;
        stackLeak();
    }

    public static void main(String[] args) throws Throwable {
        StackOOMSamples oomSamples = new StackOOMSamples();

        try {
            oomSamples.stackLeak();
        } catch (Throwable e) {
            System.out.println("stack length: " + oomSamples.stackLength);
            throw e;
        }
    }
}
